import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

class TranslateResultLandscapeController extends GetxController {

  String checkFinnalToText = '';
  String checkFinnalFromText = '';

  var screenWidth = 0.0.obs;
  var screenHeight = 0.0.obs;



  var sourceContent = ''.obs;
  var targetContent = ''.obs;

  @override
  void onInit() {
    super.onInit();
    WidgetsFlutterBinding.ensureInitialized();

    SchedulerBinding.instance.addPostFrameCallback((_) {
      SystemChrome.setPreferredOrientations([
        DeviceOrientation.landscapeRight,
        DeviceOrientation.landscapeLeft,
      ]);
      _setFullScreen();
    });

    sourceContent.value = Get.parameters['source']!;
    targetContent.value = Get.parameters['target']!;
  }

  @override
  void onReady() {
    super.onReady();

    screenWidth.value = MediaQuery.of(Get.context!).size.width;
    screenHeight.value = MediaQuery.of(Get.context!).size.height;
    /*// 延迟到下一帧执行，确保布局完成
    SchedulerBinding.instance.addPostFrameCallback((_) {
      _autoScrollToBottom();
    });*/
  }

  @override
  void onClose() {
    super.onClose();


    // 页面退出时恢复系统UI（可选）
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);

    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);


  }

  void _setFullScreen() {
    SystemChrome.setEnabledSystemUIMode(
      SystemUiMode.immersiveSticky,
      // 可选：隐藏特定系统栏（根据需求选择）
      overlays: [
        // SystemUiOverlay.top,    // 显示状态栏
        // SystemUiOverlay.bottom, // 显示导航栏
      ],
    );
  }



}
